<!--#Include File="Include.asp"--><%
'==========================================
'文 件 名：Admin/QQ.asp
'文件用途：客服浮窗拉取页面
'版权所有：方卡在线
'==========================================

Call CheckAdminType("0,1",UType)
Call CheckAdminLimit(ULimit,"s_System",0)

Dim Fk_QQ_Content

'获取参数
Types=Clng(Request.QueryString("Type"))

Select Case Types
	Case 1
		Call QQBox() '读取客服浮窗
	Case 2
		Call QQDo() '设置客服浮窗
	Case 3
		Call QQDel() '删除QQ
	Case 4
		Call QQSkin() '设置皮肤
End Select

'==========================================
'函 数 名：QQBox()
'作	用：读取客服浮窗
'参	数：
'==========================================
Sub QQBox()
	On Error Resume Next
	Rs.Open "[Fk_QQ]",Conn,1,1
	If Not Err.number=0 Then
		Err.Clear
		Conn.execute("Create TABLE [Fk_QQ]([id] AUTOINCREMENT(1,1) NOT NULL, [title] varchar(50), [qq] varchar(50), [ordnum] SmallInt,primary key(id));")
		Rs.Close
	End If
	Rs.Close
	Rs.Open "[Fk_QQ_Set]",Conn,1,1
	If Not Err.number=0 Then
		Err.Clear
		Conn.execute("Create TABLE [Fk_QQ_Set]([id] AUTOINCREMENT(1,1) NOT NULL, [skin] varchar(50),primary key(id));")
		Conn.execute("INSERT INTO [Fk_QQ_Set] (skin) VALUES('default');")
		Rs.Close
	End If
	Rs.Close
%>

	<div id="searchLine" class="font_bold">
		QQ客服管理
	</div>

	<table width="600" bordercolor="#CCCCCC" border="1" cellspacing="0" cellpadding="0">
		<tr>
			<th align="center">序号</th>
			<th align="center">客服名称</th>
			<th align="center">QQ号码</th>
			<th align="center">排序</th>
			<th align="center">操作</th>
		</tr>
<%
	Sqlstr="Select * From [Fk_QQ] Order By ordnum desc"
	Rs.Open Sqlstr,Conn,1,1
	If Not Rs.Eof Then
		i=1
		While Not Rs.Eof
%>
			<tr>
				<td height="20" align="center"><%=i%></td>
				<td align="center"><%=Rs("title")%></td>
				<td align="center"><%=Rs("qq")%></td>
				<td align="center"><%=Rs("ordnum")%></td>
				<td align="center">
					<a href="javascript:;" onclick="qqedit('<%=Rs("id")%>','<%=Rs("title")%>','<%=Rs("qq")%>','<%=Rs("ordnum")%>');">修改</a>
					<a href="QQ.asp?Type=3&Id=<%=Rs("id")%>" target="delete" confirmStr="您确认要删除“<%=Rs("qq")%>”？此操作不可逆！" refreshUrl="QQ.asp?Type=1" showStr="QQ删除成功！">删除</a>
				</td>
			</tr>
<%
			Rs.MoveNext
			i=i+1
		Wend
	Else
%>
			<tr>
				<td height="25" colspan="20" align="center">暂无记录</td>
			</tr>
<%
	End If
	Rs.Close
%>
	</table>
	<div style="width:600px;margin:10px 0;">
		<form method="post" name="QQAdd" method="post" target="ajax" action="QQ.asp?Type=2" showStr="客服QQ添加/修改成功！" refreshUrl="QQ.asp?Type=1">
			&#12288;
			<input type="hidden" name="id" id="edit_id">
			客服名称：
			<input name="title" type="text" id="edit_title" class="input" style="width:90px;" />
			QQ号码：
			<input name="qq" type="text" id="edit_qq" class="input" style="width:90px;" />
			顺序：
			<input name="ordnum" type="text" id="edit_ordnum" maxlength="2" class="input" style="width:30px;" />
			数字大的靠前
			<input type="submit" class="button" name="Enter" id="Enter" value="添加/修改" />
		</form>
	</div>
	<div style="width:600px;margin:10px 0;">
		&#12288;调用代码：
		<input type="text" class="input" id="QQKFURL" style="width:400px;" value="&lt;script src=&quot;{$SiteDir$}Plugin/QQ/qq.asp&quot;&gt;&lt;/script&gt;" />
	</div>
	
	<div style="width:600px;margin:10px 0;">
		<form method="post" name="QQSkin" method="post" target="ajax" action="QQ.asp?Type=4" showStr="客服皮肤修改成功！" refreshUrl="QQ.asp?Type=1">
		 &#12288;选择要显示的QQ客服主题：
		<select id="skinlist" name="skin">
<%
	Set Rs = Conn.execute("select top 1 * From [Fk_QQ_Set]")
	Dim nowSkin
	nowSkin = Rs("skin")
	TempArr=Split(FKFun.GetFloderList("../Plugin/QQ/"),"||")
	For Each Temp In TempArr
%>
	<option value="<%=Temp%>"<%=FKFun.BeSelect(nowSkin,Temp)%>><%=Temp%></option>
<%
	Next
%>
		</select>
		<input type="submit" class="button" name="Enter" value="确定" />
		</form>
	</div>

	

<script type="text/javascript">
function qqedit(id,title,qq,ordnum) {
	$('#edit_id').val(id);
	$('#edit_title').val(title);
	$('#edit_qq').val(qq);
	$('#edit_ordnum').val(ordnum);
	return true;
}
function setSkin(skin){
	var str='Plugin/QQ/qq.asp?skin=default';
	if(skin!=''){
		str='Plugin/QQ/qq.asp?skin='+skin
	}
	str='<'+'script src="{'+'$'+'SiteDir'+'$'+'}'+str+'">'+'<'+'/'+'script'+'>';
	$('#QQKFURL').val(str);
}
</script>
<%
End Sub

'==========================================
'函 数 名：QQDo()
'作	用：设置客服浮窗
'参	数：
'==========================================
Sub QQDo()
	Dim title,qq,ordnum,id
	id =Trim(Request.Form("id"))
	title =Trim(Request.Form("title"))
	qq=Trim(Request.Form("qq"))
	ordnum=Trim(Request.Form("ordnum"))
	
	Call FKFun.JsonString(title,1,50,0,"请输入客服名称！","名称不能大于50个字符！")
	Call FKFun.JsonString(qq,6,13,0,"请输入QQ号码！","QQ号码不能大于13个字符！")
	Call FKFun.JsonNum(qq,"QQ号码必须是数字！")
	Call FKFun.JsonNum(ordnum,"顺序必须是数字！")
	If id <> "" Then
		Call FKFun.JsonNum(id,"ID非法！")
		Sqlstr="Select title,qq,ordnum From [Fk_QQ] Where id=" & id
		Rs.Open Sqlstr,Conn,1,3
		If Not Rs.Eof Then
			Application.Lock()
			Rs("title")=title
			Rs("qq")=qq
			Rs("ordnum")=ordnum
			Rs.Update()
			Application.UnLock()
			'Response.Write("ok")
		Else
			Response.Write("要修改的QQ不存在！")
		End If
		Rs.Close
		Call FKFun.JsonSuccess()
		Response.End
	End If
	
	Sqlstr="Select title,qq,ordnum From [Fk_QQ] Where qq='"&qq&"'"
	Rs.Open Sqlstr,Conn,1,3
	If Rs.Eof Then
		Application.Lock()
		Rs.AddNew()
		Rs("title")=title
		Rs("qq")=qq
		Rs("ordnum")=ordnum
		Rs.Update()
		Application.UnLock()
		Call FKFun.JsonSuccess()
	Else
		Rs.Close
		Call FKFun.JsonError("该自定义标签已经存在！")
	End If
	Rs.Close
End Sub

Sub QQDel()
	Id=Trim(Request.QueryString("Id"))
	Call FKFun.ShowNum(Id,"系统参数错误，请刷新页面！")
	Sqlstr="Select id From [Fk_QQ] Where id=" & Id
	Rs.Open Sqlstr,Conn,1,3
	If Not Rs.Eof Then
		Application.Lock()
		Rs.Delete()
		Application.UnLock()
		Response.Write("ok")
	Else
		Response.Write("要删除的QQ不存在！")
	End If
	Rs.Close
	
End Sub

Sub QQSkin()
	Dim skin
	skin=Trim(Request.Form("skin"))
	If skin="" Then skin="default"
	Sqlstr="Update [Fk_QQ_Set] SET skin='"& skin &"'"
	Conn.execute(Sqlstr)
	Call FKFun.JsonSuccess()
	Response.End
End Sub


Call FKFun.PageEnd()
%>